package com.example.redisdemo.controller;

import jakarta.annotation.Resource;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

@RestController
@RequestMapping("lll")
public class TestController {

    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @GetMapping("test")
    public String test(){
        redisTemplate.opsForSet().add("userList",new String[]{"user1","user2","user3"});
        Set<Object> userList = redisTemplate.opsForSet().members("userList");
        System.out.println("userList = " + userList);
        return "测试成功！";
    }
}
